<template>
  <div class="goods-list flex flex-wrap mar-r--15 mar-b-15">
    <div v-for="(item, index) in goodsData" :key="index" class="mar-r-15 mar-b-15 cursor-p" @click="goodsEls(item)">
      <el-image class="image" :src="item.goodsImageUrl" lazy />
      <div class="bgc-white goods-info">
        <div class="flex v-align-c pad-b-2">
          <div class="city flex flex-center font-12" v-if="item.shopCityName"><span>{{item.shopCityName}}</span></div>
          <span class="_line-1 brand font-16 flex-item">{{item.shopName}}</span>
        </div>
        <div class="flex flex-between height-38">
          <div class="_line-2 font-color-6">{{item.title}}</div>
        </div>
        <div class="price font-price font-18 font-w pad-t-8 pad-b-9">￥ {{item.distributePrice}}</div>
        <div class="flex flex-between v-align-b font-12">
          <div class="flex goods-tags">
            <div v-for="(item, index) in item.goodsTagList" :key="index">
              <div class="width-60 height-60 position-r cursor-p">
                <img :src="item.icon" alt="" class="width-15 height-15">
              </div>
            </div>
            <!-- <div class="flex flex-center tag-1"><span>退</span></div>
            <div class="flex flex-center tag-2"><span>图</span></div>
            <div class="flex flex-center tag-3"><span>微</span></div>
            <div class="flex flex-center tag-4"><span>推</span></div> -->
          </div>
          <div class="font-color-9">{{item.createTime.slice(0,10)}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
  import {
    defineComponent,
    ref,
    onMounted,
    watch
  } from 'vue'
  import {
    useRouter
  } from 'vue-router'
  import {
    jumpPage
  } from '@/utils/jumpPageUtils'
  import noneData from '@/components/noneData/index.vue'
  export default defineComponent({
    name: 'GoodsList',
    props: {
      goodsDataList: Object
    },
    setup(props) {
      const router = useRouter()
      const goodsData = ref([])

      goodsData.value = props.goodsDataList

      watch(() => props.goodsDataList, (newVal, oldVal) => {
        goodsData.value = newVal
      })

      onMounted(() => {

      })

      const goodsEls = (item: any) => {
        jumpPage(router, 1, 1, 2001, '?goodsId=' + item.goodsId, null)
        // jumpPage(router, 1, 2, 2001, 'https://www.baidu.com')
      }

      return {
        goodsData,
        goodsEls
      }
    }
  })
</script>

<style lang="scss" scoped>
  $darkBlue: #182245;

  .goods-list {
    .el-image {
      width: 268px;
      height: 268px;
      display: block;
      cursor: pointer;
    }

    .goods-info {
      width: 268px;
      height: 142px;
      padding: 8px 10px 9px 10px;
      box-sizing: border-box;
      overflow: hidden;

      .city {
        background: $darkBlue;
        color: #fff;
        height: 18px;
        margin-right: 7px;
        padding: 0 4px;
      }

      .goods-tags {
        >div {
          width: 20px;
          height: 20px;
          margin-right: 4px;

          &.tag-1 {
            background: #e0fbfa;
            color: #00ACA7;
          }

          &.tag-2 {
            background: #e1eeff;
            color: #2A7CE6;
          }

          &.tag-3 {
            background: #e1eeff;
            color: #2A7CE6;
          }

          &.tag-4 {
            background: #e1eeff;
            color: #2A7CE6;
          }
        }
      }
    }

    ._line-1 {
      /* line-height: 1.4; */
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
      word-break: break-word;
    }

    ._line-2 {
      /* line-height: 1.4; */
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      word-break: break-word;
    }
  }
</style>
